import Vue from 'vue'
import Router from 'vue-router'
import First from '@/components/First'
import Sec from '@/components/Sec'
import Third from '@/components/Third'
import isNotVip from '@/components/isNotVip'
import SuccessNormal from '@/components/SuccessNormal'
import constants from './constants'

Vue.use(Router)

const router = new Router({
  routes: [{
    path: '/',
    name: 'First',
    component: reslove => require(['../components/First'], reslove)
  },{
    path: '/Sec',
    name: 'Sec',
    props: {name: 'garrett'},
    component: reslove => require(['../components/Sec'], reslove)
  },{
    path: '/Third',
    name: 'Third',
    component: reslove => require(['../components/Third'], reslove)
  },{
    path: '/isNotVip',
    name: 'isNotVip',
    component: reslove => require(['../components/isNotVip'], reslove)
  },{
    path: '/SuccessNormal',
    name: 'SuccessNormal',
    component: reslove => require(['../components/SuccessNormal'], reslove)
  }]
})
//导航后置守卫，可以在确定导航到目标页面时再更改title
router.afterEach((to, from) => {
  window.document.title = constants[to.name];
})

export default router;
